
<div id='jqxTabs'>
	<ul>
		<li>Detall producte: </li>
	</ul>
	<div style="padding: 5px 0 0 5px">
		<form method="<?echo $this->form->getMethod() ?>" action="<?echo $this->form->getAction()?>" id="<?echo $this->form->getId()?>" enctype="<?echo $this->form->getEnctype()?>">
		<?php	
			echo $this->form->submit->renderViewHelper();
		?>
		<input type="button" value="Tancar sense guardar" id="tornar" name="tornar" onclick="history.back()">
		<input type="button" value="Esborrar imatge" id="esborrarImatge" name="esborrarImatge">
		<?			
			echo $this->errorForm;
			
			echo $this->form->id_producto->renderViewHelper();
			
			echo $this->form->tipo_registro->renderViewHelper();
			
			echo $this->form->titulo->renderLabel(); 
			echo $this->form->titulo->renderViewHelper();
			
			echo $this->form->descripcion->renderLabel(); 
			echo $this->form->descripcion->renderViewHelper();
			
			echo $this->form->tipo_producto->renderLabel();
			?>
			<div id='jqxComboBox'></div>
			<?php 
			echo $this->form->tipo_producto->renderViewHelper();
			
			echo $this->form->fecha->renderLabel();
			?>
			<div id='jqxDateWidget'></div>
			<?php  
			echo $this->form->fecha->renderViewHelper();
			
			echo $this->form->documento->renderLabel();
			echo $this->form->documento->renderViewHelper();
			
			echo $this->form->empresa->renderLabel();
			?>
			<div id='jqxComboBoxEmpresa'></div>
			<?php  
			echo $this->form->empresa->renderViewHelper();
			
			echo $this->form->contacto->renderLabel(); 
			echo $this->form->contacto->renderViewHelper();
			
			echo $this->form->telefono->renderLabel(); 
			echo $this->form->telefono->renderViewHelper();			
			
			echo $this->form->email->renderLabel(); 
			echo $this->form->email->renderViewHelper();
			?>
			<div>
				<?php 
				if($this->form->imagen->getValue() !='')
				{
					$url = $this->form->imagen->getValue();
					echo "<img src='$url' alt='' >";
				}
				?>
			</div>
			<?php			
			echo $this->form->imagen->renderViewHelper();
			echo $this->form->file->renderViewHelper();
			
			echo $this->form->documento->renderViewHelper();
			?>
		</form>
	</div>
</div>
<script type="text/javascript">		
	$(document).ready(function () {
		var theme = getTheme();
		$("#jqxDateWidget").jqxDateTimeInput({
			theme: theme,
			width: '170px',
			height: '25px',
			formatString: 'dd MMMM yyyy',
			firstDayOfWeek: 1
			
		});
		$.getScript('/js/jqwidgets/globalization/jquery.glob.es-CA.js', function () {
            $("#jqxDateWidget").jqxDateTimeInput({ culture: 'es-CA' });
        });

		$('#jqxDateWidget').bind('valuechanged', function (event) {
            var date = event.args.date;            
			$('#fecha').val(formateaFecha(date));
        });

        if($('#fecha').val() !='')
        {
        	var fecha = $('#fecha').val();
            var month=fechaSplit('month', fecha);
            month--;
            $('#jqxDateWidget').jqxDateTimeInput('setDate', new Date(
            		fechaSplit('year', fecha), 
                    month, 
                    fechaSplit('day', fecha))
           	); 
        }
        else
        {
            var date = $('#jqxDateWidget').jqxDateTimeInput('getDate');
        	$('#fecha').val(formateaFecha(date));
        }

		//Crea el combo tipo de producto
        jqxCreaComboList("/listados/productes/nozero/0", "#jqxComboBox", "#tipo_producto");        
        var value = $('#tipo_producto').val();
        if(value== false) 
        {
        	$('#tipo_producto').val();
            value=0;
        }
        comboValue("#jqxComboBox", value);

        //Crea el combo tipo de producto
        jqxCreaComboList("/listados/empreses", "#jqxComboBoxEmpresa", "#empresa");
        var valor = $('#empresa').val();
        if(valor == false) 
        {
        	$('#empresa').val();
            valor=0;
        }
        comboValue('#jqxComboBoxEmpresa', valor);

        $('#esborrarImatge').click(function(){
        	if(confirm('Vol esborrar la imatge?'))
        		borraImagen("/eliminar/foto-productos/value/<?php echo $this->form->id_producto->getValue()?>");
        });

        
        $('#jqxNavigationBar').jqxNavigationBar('expandAt', 3);
        
    });
</script>
